﻿using System.Collections.Generic;
using System.Threading.Tasks;

using KSOAdmin.Core.Log;
using KSOAdmin.Core.Other;
using KSOAdmin.IServices.System;
using KSOAdmin.Models.Core;

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

using StackExchange.Redis;

namespace KSOAdmin.WebApi.Controllers
{
    /// <summary>
    /// 菜单
    /// </summary>
    [ApiController]
    [Authorize]
    [ApiExplorerSettings(GroupName = "系统")]
    public class Sys_MenuController : BaseApiControllers
    {
        public readonly ISys_MenuServices _MenuServices;
        public Sys_MenuController(ISys_MenuServices menuServices)
        {
            this._MenuServices = menuServices;
        }

        /// <summary>
        /// 加载此人的树形菜单
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [Route("GetRoleMenu")]
        public async Task<ResponseModel> GetRoleMenuAsync()
        {
            //string strUserId = HttpContext.User.Claims.ToList().Where(w => w.Type == "sid").FirstOrDefault()?.Value;
            List<Dictionary<string,object>> keyValues=  await _MenuServices.GetRoleMenu(true);
            return ResponseModel.Success("返回成功",keyValues);
        }

        /// <summary>
        /// 获取全部的菜单
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [Route("GetALLMenu")]
        public async Task<ResponseModel> GetALLMenuAsync() 
        {
            Logging.Info(Models.MapperModels.Enums.LoggerType.Info, "菜单执行成功", "菜单menu", 200, true);
            return ResponseModel.Success("返回成功", await _MenuServices.GetAllMenu());
        }
         
    }
}
